<!--
	作者：1055471363@qq.com
	时间：2017-12-12
	描述：焊线图片
-->
<html>

	<head>
		<meta charset="utf-8">
		<title>焊线图片</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<!--标准mui.css-->
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../css/jquery.touchPDF.css" />
		<!--App自定义的css-->
		<style type="text/css">
			.mui-bar {
				background-color: #0088BB;
			}
			
			.mui-title {
				color: #FFFFFF
			}
			
			a {
				color: #FFFFFF
			}
			/*p img {
				max-width: 100%;
				height: auto;
			}
			
			.mui-content>.mui-table-view:first-child {
				margin-top: 0;
			}*/
			/*body,
			html {
				background-color: #404040;
				height: 100%;
				padding: 0;
				margin: 0;
			}*/
			/*body,
			.mui-content {
				background-color: #FFFFFF;
			}*/
			
			.mui-preview-image.mui-fullscreen {
				position: fixed;
				z-index: 20;
				background-color: #000;
			}
			
			.mui-preview-header,
			.mui-preview-footer {
				position: absolute;
				width: 100%;
				left: 0;
				z-index: 10;
			}
			
			.mui-preview-header {
				height: 44px;
				top: 0;
			}
			
			.mui-preview-footer {
				height: 50px;
				bottom: 0px;
			}
			
			.mui-preview-header .mui-preview-indicator {
				display: block;
				line-height: 25px;
				color: #fff;
				text-align: center;
				margin: 15px auto 4;
				width: 70px;
				background-color: rgba(0, 0, 0, 0.4);
				border-radius: 12px;
				font-size: 16px;
			}
			
			.mui-preview-image {
				display: none;
				-webkit-animation-duration: 0.5s;
				animation-duration: 0.5s;
				-webkit-animation-fill-mode: both;
				animation-fill-mode: both;
			}
			
			.mui-preview-image.mui-preview-in {
				-webkit-animation-name: fadeIn;
				animation-name: fadeIn;
			}
			
			.mui-preview-image.mui-preview-out {
				background: none;
				-webkit-animation-name: fadeOut;
				animation-name: fadeOut;
			}
			
			.mui-preview-image.mui-preview-out .mui-preview-header,
			.mui-preview-image.mui-preview-out .mui-preview-footer {
				display: none;
			}
			
			.mui-zoom-scroller {
				position: absolute;
				display: -webkit-box;
				display: -webkit-flex;
				display: flex;
				-webkit-box-align: center;
				-webkit-align-items: center;
				align-items: center;
				-webkit-box-pack: center;
				-webkit-justify-content: center;
				justify-content: center;
				left: 0;
				right: 0;
				bottom: 0;
				top: 0;
				width: 100%;
				height: 100%;
				margin: 0;
				-webkit-backface-visibility: hidden;
			}
			
			.mui-zoom {
				-webkit-transform-style: preserve-3d;
				transform-style: preserve-3d;
			}
			
			.mui-slider .mui-slider-group .mui-slider-item img {
				width: auto;
				height: auto;
				max-width: 100%;
				max-height: 100%;
			}
			
			.mui-android-4-1 .mui-slider .mui-slider-group .mui-slider-item img {
				width: 100%;
			}
			
			.mui-android-4-1 .mui-slider.mui-preview-image .mui-slider-group .mui-slider-item {
				display: inline-table;
			}
			
			.mui-android-4-1 .mui-slider.mui-preview-image .mui-zoom-scroller img {
				display: table-cell;
				vertical-align: middle;
			}
			
			.mui-preview-loading {
				position: absolute;
				width: 100%;
				height: 100%;
				top: 0;
				left: 0;
				display: none;
			}
			
			.mui-preview-loading.mui-active {
				display: block;
			}
			
			.mui-preview-loading .mui-spinner-white {
				position: absolute;
				top: 50%;
				left: 50%;
				margin-left: -25px;
				margin-top: -25px;
				height: 50px;
				width: 50px;
			}
			
			.mui-preview-image img.mui-transitioning {
				-webkit-transition: -webkit-transform 0.5s ease, opacity 0.5s ease;
				transition: transform 0.5s ease, opacity 0.5s ease;
			}
			
			@-webkit-keyframes fadeIn {
				0% {
					opacity: 0;
				}
				100% {
					opacity: 1;
				}
			}
			
			@keyframes fadeIn {
				0% {
					opacity: 0;
				}
				100% {
					opacity: 1;
				}
			}
			
			@-webkit-keyframes fadeOut {
				0% {
					opacity: 1;
				}
				100% {
					opacity: 0;
				}
			}
			
			@keyframes fadeOut {
				0% {
					opacity: 1;
				}
				100% {
					opacity: 0;
				}
			}
			
			p img {
				max-width: 100%;
				height: auto;
			}
		</style>

	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">焊线图片</h1>
		</header>
		<div class="mui-content" id="welding">
			<div id="myPDF" v-show="fileInfo.ext=='pdf'"></div>
			<div class="mui-content-padded">

				<p v-show="fileInfo.ext=='jpg'">
					<img :src="DiagramUrl" />
				</p>

			</div>
		</div>
	</body>

</html>
<script src="../../js/mui.min.js"></script>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/pdf.compatibility.js"></script>
<script type="text/javascript" src="../../js/pdf.js"></script>
<script type="text/javascript" src="../../js/jquery.touchSwipe.js"></script>
<script type="text/javascript" src="../../js/jquery.panzoom.js"></script>
<script type="text/javascript" src="../../js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="../../js/jquery.touchPDF.js"></script>
<script type="text/javascript" src="../../base.js"></script>
<script type="text/javascript" src="../../js/vue.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../../js/mui.previewimage.js"></script>
<script type="text/javascript" src="../../js/mui.zoom.js"></script>
<script type="text/javascript">
	mui.init({
		swipeBack: true //启用右滑关闭功能
	})

	var DiagramUrl = localStorage.getItem("DiagramUrl");
	var DiagramVersion = localStorage.getItem("DiagramVersion")
	console.log(DiagramUrl)
	var vm = new Vue({
		el: "#welding",
		data: {
			DiagramUrl: '',
			DiagramVersion: '',
			ext: '', //文件类型
			fileInfo: {}
		},
		mounted: function() {
			this.getFileExt();
		},
		methods: {
			getFileExt: function() {
				//				alert(DiagramUrl)
				var _this = this
				mui.ajax(base + '/WeldingDrawing/index.json', {
					data: {
						htmlfileName: DiagramUrl
					},
					dataType: 'json', //服务器返回json格式数据
					type: 'post', //HTTP请求类型
					timeout: 30000, //超时时间设置为10秒；
					success: function(data) {
						console.log(data.haveFile)
						if(data.haveFile == true) {
							_this.fileInfo = data
							if(data.returnFilePath == null) {
								_this.DiagramUrl = weldingURL + data.retureFileName
							} else {
								_this.DiagramUrl = weldingURL + data.returnFilePath + '/' + data.retureFileName
							}
							_this.ext = data.ext

							if(_this.ext == 'jpg') {
								_this.images();
							} else {
								_this.pdf();
							}
						} else {
							mui.alert("文件不存在")
						}

					},
					error: function(xhr, type, errorThrown) {
						console.log(type)
					}
				});
			},
			pdf: function() {
				var _this = this
				$("#myPDF").pdf({
					source: _this.DiagramUrl,
					title: 'pdf',
					redrawOnWindowResize: true,
					showToolbar: true
				});
			},
			images: function() {
				var _this = this
				/*图片预览native模式*/
				//				var images = [].slice.call(document.querySelectorAll('.mui-content-padded img'));
				//				var urls = [];
				//				images.forEach(function(item) {
				//					urls.push(item.src);
				//				});
				//				mui('.mui-content-padded').on('tap', 'img', function() {
				//					var index = images.indexOf(this);
				//					plus.nativeUI.previewImage(urls, {
				//						current: index,
				//						indicator: 'number'
				//					});
				//				});

				//图片预览h5模式
				mui.previewImage();
			}

		}
	})
</script>